package _18define;

public class StringCount {
    public static void main(String[] args) {
        String str = "woaijavawozhenaijavawozhendeaijavawozhendehenaijavaxinbuxinwoaijavagun";
        int count = 0;

        for (int i = 0; i < str.length (); i++) {
            if (i+4>str.length()){
                break;
            }else {
                String subStr = str.substring (i, i + 4);
                if (subStr.equals("java")) {
                    count++;
                }
            }
        }
        System.out.println ("java出现了" + count + "次");
    }
}
